home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / jocoScroll / read me < prev   
Text File  |  1999-04-13  |  1KB  |  20 lines

  1. JocoScroll
  2. by Matt Neuburg
  3. matt@tidbits.com
  4. http://www.tidbits.com/matt/
  5.  
  6. Illustrates how to scroll an image (a canvas).
  7.  
  8. The project provides a canvas subclass, JocoCanvas, which knows how to scroll itself. To illustrate the subclass's flexibility, three methods of scrolling are shown: by dragging with the mouse, by using scrollbars, and by live animation.
  9.  
  10. No special RB 2 devices are used; the project just illustrates a technique people often are confused about.
  11.  
  12. After you say Scroll, when the application then goes idle, the Paint event is automatically called, and it is up to your Paint event handler to fill in the rectangle or rectangles which have just been vacated by the movement of existing pixels. However, RB helps you by automatically clipping the area affected by the Paint event to exactly the vacated regions. Thus, you can simply draw the whole canvas, and just the vacated regions will be filled in.
  13.  
  14. On the other hand, when you say Scroll in a loop, the application never goes idle, so it is up to you to fill in the vacated area. Here, this is done by emulating what RB would have done: we cause the Paint event to fire, clipping its effective area to the vacated region, by using refreshRect.
  15.  
  16. Therefore, all you really have to do is keep track of the image's position relative to the canvas, and use this information when the time comes to redraw. That's basically what the JocoCanvas subclass does.
  17.  
  18. From my upcoming book on REALbasic. m.
  19.  
  20.